﻿namespace Borg.AddOn
{
    internal sealed class TypeStorePermissionHookChain : ITypeStorePermissionHook
    {
        private readonly ITypeStorePermissionHook[] _hooks;

        public TypeStorePermissionHookChain(ITypeStorePermissionHook[] hooks)
        {
            _hooks = hooks;
        }

        public bool CanAdd(Contract contract, out LogArgs log)
        {
            foreach (ITypeStorePermissionHook hook in _hooks)
                if (!hook.CanAdd(contract, out log))
                    return false;

            log = null;
            return true;
        }

        public bool CanAdd(Plugin plugin, out LogArgs log)
        {
            foreach (ITypeStorePermissionHook hook in _hooks)
                if (!hook.CanAdd(plugin, out log))
                    return false;

            log = null;
            return true;
        }
    }
}

